#include "JCCGainTypeSDifSize.h"

using namespace JCC::TOOL;

#define HEAD_ADDR(mem) (_addrs.push_back((unsigned long)(&mem)))

CJCCGainTypeSDifSize::CJCCGainTypeSDifSize(void)
{
	_typedifsize = new std::vector<int>;

	GainTypeDifSize();
}

CJCCGainTypeSDifSize::~CJCCGainTypeSDifSize(void)
{
	delete _typedifsize;
}

int& JCC::TOOL::CJCCGainTypeSDifSize::operator[]( int index_ )
{
	int ret = 0;

	if(index_ >= 0 && index_ < _typedifsize->size())
	{
		return (*_typedifsize)[index_];
	}
	else
	{
		throw index_;
	}

	return ret;
}

void JCC::TOOL::CJCCGainTypeSDifSize::GainTypeDifSize()
{
	std::vector<unsigned long> _addrs;

	HEAD_ADDR( _char);
	HEAD_ADDR(_pchar);

	HEAD_ADDR(_uchar);
	HEAD_ADDR(_puchar);

	HEAD_ADDR(_int);
	HEAD_ADDR(_pint);

	HEAD_ADDR(_uint);
	HEAD_ADDR(_puint);

	HEAD_ADDR(_long);
	HEAD_ADDR(_plong);

	HEAD_ADDR(_ulong);
	HEAD_ADDR(_pulong);

	HEAD_ADDR(_longlong);

	HEAD_ADDR(_string);

	HEAD_ADDR(_jccstr);

	HEAD_ADDR(_typedifsize);

	for(int i=1; i<_addrs.size(); i++)
	{
		_typedifsize->push_back(_addrs[i] - _addrs[i - 1]);
	}

	_typedifsize->push_back(0);
}